export default class desensitizedUtils {
	//手机号脱敏
	static desensitizedPhone(phone) {
		return phone.replace(/(\d{3})\d*(\d{4})/, '$1****$2');
	}
	//邮箱脱敏
	static desensitizedEmail(email) {
		return email.replace(/(.{0,3}).*@(.*)/, "$1***@$2")
	}
	static checkField(string,type) {
		switch (type) {
			case 'phone':
				let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
				if (!checkPhone.test(string)) {
					return '请输入正确得手机号码！'
				} else {
					return ''
				}
			case 'email':
				let checkEmail = new RegExp(
					/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
				)
				if (!checkEmail.test(string)) {
					return '请输入正确得邮箱'
				} else {
					return ''
				}
		}
	}
	//校验邮箱
	static checkEmail(email) {
		let checkEmail = new RegExp(
			/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
		)
		if (!checkEmail.test(email)) {
			return '请输入正确得邮箱'
		} else {
			return ''
		}

	}
	//校验手机
	static checkPhone(phone) {
		let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
		if (!checkPhone.test(phone)) {
			return '请输入正确得手机号码！'
		} else {
			return ''
		}

	}
}
